package com.example.polarity;

import android.R.interpolator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

public class Astroids extends ImageView 
{
	
	int ScreenWidth = 0;
	int ScreenHeight = 0;
	int rotation = 1;
	public Astroids(Context context) 
	{	
		super(context);
		// TODO Auto-generated constructor stub
	}
	
	@SuppressLint("NewApi")
	public Astroids(Context context, AttributeSet attrs) 
	{
		super(context, attrs);
		this.setWillNotDraw(false);

		DisplayMetrics metrics = context.getResources().getDisplayMetrics();
		ScreenWidth  = metrics.widthPixels;
		ScreenHeight = metrics.heightPixels;
		
	}
	
	public Astroids(Context context, AttributeSet attrs, int defStyle) 
	{
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	
	 @Override
	 protected void onDraw(Canvas canvas) 
	 {

		 if(this.getX() <  (-1 * this.getWidth()))
			 this.setX(ScreenWidth);
		 
		 this.setRotation(rotation);
		 this.setX( (float)(this.getX() - 3)); 
		   
		 rotation++;
		 
		 if(rotation == 360)
			 rotation = 1;
		 
		 invalidate();
		 
	 }


}
